#ifndef _GCRYPT_H
#define	_GCRYPT_H
#include <openssl/rand.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/ossl_typ.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/pem.h>
#include <openssl/aes.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <memory.h>

class GCrypt {
public:
    GCrypt();
    ~GCrypt();
    int Init(const char * cert_path,const char * private_path);
	int Init(const char * cert_path);
	   
    int load_cert_from_file(const char* cert_puth);
    int load_private_key_from_file(const char *private_key_path);
	
	RSA * get_cert_public_key(const char * path_to_cert);
	const char* get_cert_into_buffer(int &len);
	std::string get_cert_path();
	
	int GetPrivateKeySize();
    int GetPublicKeySize();
	unsigned char *generate_key();
    
	unsigned char *rsa_encrypt(unsigned char * buffer_to_enc,int buf_len);
    unsigned char *rsa_decrypt(unsigned char * buffer_to_dec,int buf_len);
    
    static unsigned char * aes_encrypt(unsigned char* in_buffer,int buf_len,unsigned char* key, int* enc_len);
    static unsigned char * aes_decrypt(unsigned char* in_buffer,int buf_len,unsigned char* key);
    
//private:
    std::string certWithTags;
    char * cert_buf;
    RSA * private_key;
    std::string path_to_cert;	
    unsigned char * aes_key;
    int aes_key_len;
    RSA * pub_key;
    unsigned char* enc_key;
};

#endif	/* _CGCRYPT_H */
